{include file='public/head'}

<body class="index">
    <!-- 顶部开始 -->
    <div class="container">
        <div class="logo">
            <a href="/admin.php">安安游官网</a>
        </div>
        <div class="left_open">
            <a><i class="layui-icon" title="展开左侧栏">&#xe668;</i></a>
        </div>

        <div class="shuaxin" style="margin-left: 25px;">
            <a class="top-refresh"><i class="layui-icon layui-icon-refresh" style="background: rgba(0,0,0,0);"
                    title="刷新"></i></a>
        </div>

        <ul class="layui-nav right" lay-filter="">
            <li class="layui-nav-item" lay-unselect="">
                <a href="app/message/index.html" title="消息中心">
                    <i class="layui-icon layui-icon-notice"></i>
                </a>
            </li>
            <li class="layui-nav-item layui-hide-xs" lay-unselect="">
                <a href="/" target="_blank" title="前台">
                    <i class="layui-icon layui-icon-website"></i>
                </a>
            </li>
            <li class="layui-nav-item layui-hide-xs" lay-unselect="" title="全屏">
                <a href="javascript:" id="fullscreen">
                    <i class="layui-icon layui-icon-screen-full"></i>
                </a>
            </li>
            <li class="layui-nav-item" lay-unselect>
                <a href="javascript:;"><i class="layui-icon layui-icon-theme"></i>Theme</a>
                <dl class="layui-nav-child">
                    <!-- 二级菜单 -->
                    <dd>
                        <a href="javascript:setTheme('white-black')">阿修罗</a>
                    </dd>
                    <dd>
                        <a href="javascript:setTheme('black')">黑武士</a>
                    </dd>
                    <dd>
                        <a href="javascript:setTheme('girl')">紫霞仙子</a>
                    </dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-unselect>

                <a href="javascript:;"><i class="layui-icon layui-icon-username"></i>{:session('username')}</a>
                <dl class="layui-nav-child">
                    <!-- 二级菜单 -->
                    <dd>
                        <a onclick="xadmin.open('修改密码','{:url(\'admin/user/editPasswd\')}')">修改密码</a>
                    </dd>
                    <dd>
                        <a href="javascript:logout()">注销账号</a>
                    </dd>
                </dl>
            </li>

        </ul>
    </div>
    <!-- 顶部结束 -->
    <!-- 中部开始 -->
    {include file='public/left'}
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="layui-tab tab tab" lay-allowclose="false" lay-filter="xbs_tab">
            <ul class="layui-tab-title">
                <li class="home layui-this" lay-id="home">
                    <i class="layui-icon">&#xe68e;</i>我的桌面
                </li>
            </ul>
            <div class="layui-unselect layui-form-select layui-form-selected" id="tab_right">
                <dl>
                    <dd data-type="this">关闭当前</dd>
                    <dd data-type="other">关闭其它</dd>
                    <dd data-type="all">关闭全部</dd>
                </dl>
            </div>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <iframe class="x-iframe" frameborder="0" scrolling="yes"
                        src="{:url('admin/index/welcome')}"></iframe>
                </div>
            </div>
            <div id="tab_show"></div>
        </div>
    </div>
    <div class="page-content-bg"></div>
    <style id="theme_style"></style>
</body>
<script>
    //注销方法
    function logout() {
        $.ajax({
            url: "{:url('admin/login/logout')}",
            type: 'post',
            dataType: 'json',
            data: {},
        }).done(function (data) {
            if (data.code == 0) {
                layer.msg(data.msg);
            } else {
                layer.msg(data.msg, { icon: 1, offset: 't' }, function () {
                    location.href = data.url;
                });

            }
        })
    }

    function getNoticeNums() {
        $.ajax({
            url: "{:url('admin/notice/nums')}",
            type: 'get',
            dataType: 'json',
        }).done(function (res) {
            if (res.code == 1) {
                let data = res.data.nums;
                if (data.length > 0) {
                    for (let i = 0; i < data.length; i++) {
                        let id = '#rule_' + data[i].rule_id;
                        $(id).text(data[i].num);
                        if (data[i].num > 0) {
                            $(id).show();
                        } else {
                            $(id).hide();
                        }
                        if (data[i].total > 0) {
                            $(id).closest('ul').closest('li').find('.layui-icon-notice').show();
                        } else {
                            $(id).closest('ul').closest('li').find('.layui-icon-notice').hide();
                        }
                    }
                }
            }
        })
    }

    $(function () {
        getNoticeNums();
        setInterval(function () {
            getNoticeNums();
        }, 300000);
    })
</script>
{include file='public/foot'}